-- Quick tip: AppleScript application toggle - BrettTerpstra.com-- http://brettterpstra.com/2011/01/22/quick-tip-applescript-application-toggle/use AppleScript version "2.4" -- Yosemite (10.10) or lateruse scripting additionsset appName to "Mail"set startIt to falsetell application "System Events"	if not (exists process appName) then		set startIt to true	else if frontmost of process appName then		set visible of process appName to false	else		set frontmost of process appName to true	end ifend tellif startIt then	tell application appName to activateend if